import fly from "../main"

/**
 * 获取宠物列表
 * @returns {Promise<{}>}
 */
export async function getPets() {
  let response = {}
  await fly.get(`/v3/pet`).then((res) => {
    response = res.data
  })
  return response;
}

/**
 * 添加宠物信息
 * @param $pet 宠物数据
 * @returns {Promise<{}>}
 */
export async function addPet($pet) {
  let response = {}
  await fly.post(`/v3/pet`, $pet).then((res) => {
    response = res.data
  })
  return response;
}

/**
 * 删除宠物信息
 * @param $id 宠物id
 * @returns {Promise<{}>}
 */
export async function delPet($id) {
  let response = {}
  await fly.delete(`/v3/pet/${$id}`).then((res) => {
    response = res.data
  })
  return response;
}

/**
 * 获取宠物信息
 * @param $id 宠物id
 * @returns {Promise<{}>}
 */
export async function getPet($id) {
  let response = {}
  await fly.get(`/v3/pet/${$id}`).then((res) => {
    response = res.data
  })
  return response;
}

/**
 * 更新宠物信息
 * @param id
 * @param pet
 * @returns {Promise<{}>}
 */
export async function updatePet(id,pet) {
  let response = {}
  await fly.put(`/v3/pet/${id}`, pet).then((res) => {
    response = res.data
  })
  return response;
}
